//
//  FLDRadioGroupViewController.m
//  FLDRadioGroup
//
//  Created by 深津 貴之 on 08/12/30.
//  Copyright __MyCompanyName__ 2008. All rights reserved.
//

#import "FLDRadioGroupViewController.h"


@implementation FLDRadioGroupViewController



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	FLDRadioGroup *group = [[FLDRadioGroup alloc]init];
	group.delegate = self;	
	int n = 8;
	for(int i=0; i<n; i++)
	{
		UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
		[button setFrame: CGRectMake(20, 20+i*54, 280, 40)];
		[button setTitle:[NSString stringWithFormat:@"%d", i] forState:UIControlStateNormal];
		[button setTitle:[NSString stringWithFormat:@"SELECTED", i] forState:UIControlStateSelected];
		[button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
		[button setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
		[group addButton:button];
		[self.view addSubview:button];
	}
	[group setSelectedIndex:0];
}

-(void)radioGroup:(FLDRadioGroup*)radioGroup didSelecteButton:(UIButton*)button atIndex:(NSInteger)index
{
	NSLog(@"button is selected %@ at index %d", button, index);
}

- (void)dealloc {
    [super dealloc];
}

@end
